Skip to content

Conversation

guyutongxue
Copy link
Contributor

@guyutongxue guyutongxue commented Aug 31, 2025

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

This PR tries to map MDX Markdown node to correct JSX node. The feature request is at https://github.com/orgs/mdx-js/discussions/2639 . Before, the MDX node are translated to <></> fragment in language service, which is not typed well (see microsoft/TypeScript#62358) and this PR changes them to a slightly corrected translation, such as <p></p>.

Benefit on this, we can do type-checking on JSX expression 'hole' inside Markdown contents, such as (e.g. translate to React JSX):

image

Also some open questions:

  • The parser returns something like listItem { paragraph { innerContent } } for a compact list item, which is not the correct behavior according to CommonMark spec (says no <p> inside a
  • if compact), so the original idea of typing <li> may not work;
  • There are no source mappings of plain texts and tag names, so errors from those content's typing will be silenced;
  • Documentation updates.

Copy link

changeset-bot bot commented Aug 31, 2025

🦋 Changeset detected

Latest commit: cc9043d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@mdx-js/language-service Patch
@mdx-js/language-server Patch
@mdx-js/typescript-plugin Patch
vscode-mdx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the 👋 phase/new Post is being triaged automatically label Aug 31, 2025

This comment has been minimized.

@guyutongxue guyutongxue changed the title feat(language-service): Make MDX nodes typed with MDX.IntrinsicElements feat(language-service): Make MDX nodes typed with JSX.IntrinsicElements Sep 7, 2025
Copy link
Member

@remcohaszing remcohaszing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great, but the tests need to be adjusted, notably the tests in https://github.com/mdx-js/mdx-analyzer/blob/main/packages/language-service/test/language-plugin.js.

@github-actions github-actions bot added 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Sep 14, 2025
Copy link

codecov bot commented Sep 14, 2025

Codecov Report

❌ Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.43%. Comparing base (5c96eac) to head (cc9043d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/language-service/lib/virtual-code.js 96.49% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #515      +/-   ##
==========================================
+ Coverage   92.31%   92.43%   +0.11%     
==========================================
  Files          13       13              
  Lines        1927     1982      +55     
==========================================
+ Hits         1779     1832      +53     
- Misses        148      150       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remcohaszing
Copy link
Member

Ok this looks great! Just one small thing left: add a changeset, so we make a release.

  1. From the repo root, run:
    npx changeset
  2. Select all packages (We have to, because Changesets doesn’t fully understand VSCode extensions)
  3. Mark all packages as being patch releases
  4. Add a nice little one-liner summary

@remcohaszing remcohaszing merged commit 3f266d4 into mdx-js:main Sep 16, 2025
6 checks passed

This comment was marked as resolved.

@github-actions github-actions bot mentioned this pull request Sep 16, 2025
@remcohaszing
Copy link
Member

Thank you! ♥️ This was just released. The MDX VSCode extension update can show up any moment now.

@guyutongxue guyutongxue deleted the feat-type-md-nodes branch September 16, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually
Development

Successfully merging this pull request may close these issues.

2 participants